* (bug 23006) create #speciale parser function.
* generateSitemap can now optionally skip redirect pages.
* (bug 27757) new API command just for retrieving tokens (not page-based)
+* Added GitViewers hook for extensions using external git repositories to have a web-based
+ repository viewer linked to from Special:Version.
=== Bug fixes in 1.20 ===
* (bug 30245) Use the correct way to construct a log page title.
'getUserPermissionsErrorsExpensive': Absolutely the same, but is called only
if expensive checks are enabled.
+'GitViewers': called when generating the list of git viewers for Special:Version, use
+ this to change the list.
+&$extTypes: associative array of repo URLS to viewer URLs.
+
+
'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki
image insertion. You can skip the default logic entirely by returning
false, or just modify a few things using call-by-reference.
protected $basedir;
/**
- * Map of repo URLs to viewer URLs.
- * Key is a pattern passed to preg_match() and preg_replace(),
- * without the delimiters (which are #) and must match the whole URL.
- * The value is the replacement for the key (it can contain $1, etc.)
- * %h will be replaced by the short SHA-1 (7 first chars) and %H by the
- * full SHA-1 of the HEAD revision.
+ * Map of repo URLs to viewer URLs. Access via static method getViewers().
*/
- protected $viewers = array(
- 'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
- 'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
- );
+ private static $viewers = false;
/**
* @param $dir string The root directory of the repo where the .git dir can be found
if ( substr( $url, -4 ) !== '.git' ) {
$url .= '.git';
}
- foreach( $this->viewers as $repo => $viewer ) {
+ foreach( self::getViewers() as $repo => $viewer ) {
$pattern = '#^' . $repo . '$#';
if ( preg_match( $pattern, $url ) ) {
$viewerUrl = preg_replace( $pattern, $viewer, $url );
public static function headViewUrl() {
return self::repo()->getHeadViewUrl();
}
+
+ /**
+ * Gets the list of repository viewers
+ * @return array
+ */
+ protected static function getViewers() {
+ if( self::$viewers === false ) {
+
+ // Map of repo URLs to viewer URLs.
+ //
+ // Key is a pattern passed to preg_match() and preg_replace(),
+ // without the delimiters (which are #) and must match the whole URL.
+ // The value is the replacement for the key (it can contain $1, etc.)
+ // %h will be replaced by the short SHA-1 (7 first chars) and %H by the
+ // full SHA-1 of the HEAD revision.
+ self::$viewers = array(
+ 'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
+ 'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
+ );
+
+ wfRunHooks( 'GitViewers', array( &self::$viewers ) );
+ }
+
+ return self::$viewers;
+ }
}